package com.lsw.jgyf.ui.fragment;


import com.lsw.dialog.DialogProgress;
import com.lsw.jgyf.httpapi.HttpApi;
import com.lsw.jgyf.inject.Constants;
import com.lsw.jgyf.ui.base.presenter.BasePresenter;
import com.lsw.util.LogUtils;
import com.lsw.util.ToastUtil;

import javax.inject.Inject;

import io.reactivex.disposables.Disposable;

/**
 * Created by lsw on 2017/12/7.
 */

public class HomeFragment4Presenter extends BasePresenter<HomeFragment4Contract.View> implements HomeFragment4Contract.Presenter {
    @Inject
    HttpApi httpApi;

    @Inject
    public HomeFragment4Presenter() {
    }

    @Override
    public void uphead(String url) {
        DialogProgress progress = new DialogProgress(mContext);
        progress.show();
        Disposable disposable = httpApi
                .uphead(url)
                .subscribe(baseBean -> {
                    progress.dismiss();
                    if (baseBean.getStatus() == Constants.CODE_SUCESS) {
                        mView.upSucceed(baseBean.getData());
                    } else {
                        ToastUtil.showToast(mContext, baseBean.getMessage());
                    }
                }, throwable -> {
                    progress.dismiss();
                    LogUtils.e("TAG_Enroll", throwable.getMessage());
                });
        mCompositeDisposable.add(disposable);
    }


}
